package com.shanshi.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.shanshi.activity.response.IndexInfo;


public class MyCenter extends MainActivity implements OnClickListener{
	
	private	SharedPreferences sharedPreferences ;
	
	private TextView tv;
	private ImageView titleImg;
	private TextView myWalletTx;
	private TextView billDetailsTx;
	private TextView myCollectTx;
	private TextView mySuggestTx;
	private TextView changestoreTx;
	private TextView changeNumTx;
	private TextView exit;
	private ImageView avatar;
	private ImageView mycenter_bac;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mycenter);
		tv = (TextView) findViewById(R.id.title2);
		titleImg = (ImageView) findViewById(R.id.list);
		titleImg.setOnClickListener(this);
		tv.setText("菜叔叔");
		
		sharedPreferences = MyCenter.this.getSharedPreferences("share", MODE_PRIVATE);
		mycenter_bac = (ImageView) findViewById(R.id.mycenter_bac);
		String result = sharedPreferences.getString("indexResult", "");
		IndexInfo indexInfo = new Gson().fromJson(result, IndexInfo.class);
		Log.e("gson", "onCreate: "+indexInfo.toString() );
		Glide.with(MyCenter.this).load(indexInfo.getShopImg()).centerCrop().into(mycenter_bac);
		
		myWalletTx = (TextView) findViewById(R.id.mywallet);
		myWalletTx.setOnClickListener(this);
		billDetailsTx = (TextView) findViewById(R.id.billdetails);
		billDetailsTx.setOnClickListener(this);
		myCollectTx = (TextView) findViewById(R.id.mycollect);
		myCollectTx.setOnClickListener(this);
		mySuggestTx = (TextView) findViewById(R.id.suggest);
		mySuggestTx.setOnClickListener(this);
		changestoreTx = (TextView) findViewById(R.id.changestore);
		changestoreTx.setOnClickListener(this);
		changeNumTx = (TextView) findViewById(R.id.changeNum);
		changeNumTx.setOnClickListener(this);
		exit = (TextView) findViewById(R.id.exit);
		exit.setOnClickListener(this);
		avatar = (ImageView) findViewById(R.id.Avatar);
		Glide.with(MyCenter.this).load(R.drawable.name).centerCrop().into(avatar);
		avatar.setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		
		switch (v.getId()) {
		
		case R.id.mywallet:
			Intent mywallet = new Intent(MyCenter.this,MyWallet.class);
			startActivity(mywallet);
			break;
			
		case R.id.billdetails:
			Intent billdetails = new Intent(MyCenter.this,BillDetails.class);
			startActivity(billdetails);
		
			break;
		
		case R.id.mycollect:
			Intent mycollect = new Intent(MyCenter.this,Mycollect.class);
			startActivity(mycollect);
			break;
			
		case R.id.suggest:
			Intent suggest = new Intent(MyCenter.this,Suggest.class);
			startActivity(suggest);
			break;
		
		case R.id.changestore:
			Intent changestore = new Intent(MyCenter.this,StoreInfo.class);
			startActivity(changestore);
			break;
			
		case R.id.changeNum:
			Intent changeNum = new Intent(MyCenter.this,ChangeTelphone.class);
			startActivity(changeNum);
			break;	
			
		case R.id.exit:
			Intent exit = new Intent(MyCenter.this,LoginActivity.class);
			startActivity(exit);
			break;
			
		case R.id.Avatar:
			Intent Avatars = new Intent(MyCenter.this,MyMessage.class);
			startActivity(Avatars);
			break;	
			

			
		}
	}
}
